package com.atguigu.gulimall.cart.controller;

import com.atguigu.gulimall.cart.bean.DemoData;
import com.atguigu.gulimall.cart.util.ExcelUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@RestController
public class TestController {

    @GetMapping("/excel/download")
    public void downloadExcel(HttpServletResponse response){
        List<DemoData> list = new ArrayList<>();
        DemoData demoData = new DemoData();
        demoData.setSname("张珊珊");
        demoData.setSno("1");
        DemoData demoData1 = new DemoData();
        demoData1.setSname("李四");
        demoData1.setSno("2");
        DemoData demoData2 = new DemoData();
        demoData2.setSname("王五");
        demoData2.setSno("3");
        list.add(demoData);
        list.add(demoData1);
        list.add(demoData2);
        ExcelUtil.download(response,"熊","sheetxiong",list,DemoData.class);
    }
}
